
$(function () {

    var showInfo = JSON.parse(localStorage.getItem('submitParam'));
    var userId = localStorage.getItem('userId');
    var scores = JSON.parse(localStorage.getItem('scores'));

    requests.getReq(urls.getTeaInfo + '/' + userId, '', succeInfo, null);
    function succeInfo(data) {
        if (data.status == 1 && data.data) {
            var info = data.data;
            var arr = [
                info.userId,
                info.userName,
                commonEducation[info.education],
                info.teacherPostLevel,
                info.collegeName,
                info.researchName,
                scores.totalScore
            ];
            var itemList = '<ul class="item_list_cont">';
            $.each(arr,function (i,val) {
                itemList += '<li>'+val+'</li>';
            })
            itemList += '</ul>';
            $("#tea_info").html(itemList);
        } else {
            showTip('未查询到教师相关信息');
        }
    }
    console.log(showInfo);

    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);
    initList('worksApply','theoryWorks',['termSelect','className','period','classCategory','remark']);
    initList('worksApply','practiceWorks',['termSelect','className','period','classCategory','remark']);
    initList('worksApply','optionalWorks',['termSelect','className','period','classCategory','remark']);

    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);

    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);

    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);
    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);

    initList('worksApply','baseWorks',['termSelect','totalWorks','finish','score','remark']);

    function initList(father,id,itemArr) {
        var itemList = '';
        for(var i = 0; i<showInfo[father][id].length; i++){
            itemList += '<ul class="item_list_cont">';
            $.each(itemArr,function (index,val) {
                var cont = showInfo[father][id][i][val];
                if(val == 'termSelect'){
                    cont = compTermYear(showInfo[father][id][i].schoolYear,showInfo[father][id][i].semesterEnum)
                }
                if(val == 'classCategory'){
                    if(cont == 'THEORY'){
                        cont = '理论课';
                    }else if(cont == 'PRACTICE'){
                        cont = '实践课';
                    }else if(cont == 'OPTIONAL'){
                        cont = '选修课';
                    }else{
                        cont = '-';
                    }

                }
                cont = cont ? cont : '-'
                itemList += '<li>'+cont+'</li>';
            })
            itemList += '</ul>';
        }
        $("#"+id).html(itemList);
        if(itemList == ''){
            $("#"+id).remove();
        }
    }

    $("#baseWorks").parents('.item_block').children('h3').html('教学工作量申报（得分：'+scores.workScore+'）');

})